package cn.colins.raft.task;

import cn.colins.raft.enity.RaftNodeInfo;
import cn.colins.raft.enums.NodeStatusEnums;
import cn.colins.raft.node.RaftNodeService;

/**
 * @Description 心跳定时任务
 * @Author czl
 * @Version V1.0.0
 * @Since 1.0
 * @Date 2023/7/18
 */
public class HeartBeatTask implements Runnable {

    @Override
    public void run() {
        // 只有leader才需要发送心跳包
        if(NodeStatusEnums.LEADER.equals(RaftNodeInfo.getInstance().getCurrentNodeStatus())){
            RaftNodeService.sendHeartBeat();
        }
    }
}
